const {
	Controller
} = require('uni-cloud-router')
const uniID = require('uni-id')
module.exports = class UserController extends Controller {
	async getUserStatistics() {
		const {
			userId
		} = this.ctx.data
		if (!userId) {
			return {
				code: 500,
				msg: "参数错误"
			}
		}
		try{
			let res = await this.service.user.getUserStatistics({
				userId
			})
			return {
				code: 200,
				result: res
			}
		}catch(e){
			return {
				code: 500,
				msg: e.message
			}
		}
	}
	
	async getMemberList() {
		let {
			keyword,
			pageNum,
			pageSize
		} = this.ctx.data
		try{
			let page = await this.service.user.getMemberList({
				keyword,
				pageNum,
				pageSize
			})
			return {
				code: 200,
				result: page
			}
		}catch(e){
			return {
				code: 500,
				msg: e.message
			}
		}
	}
	
	async getShareExpertList() {
		let {
			keyword,
			isShare,
			city,
			pageNum,
			pageSize
		} = this.ctx.data
		try{
			let page = await this.service.user.getShareExpertList({
				keyword,
				isShare,
				city,
				pageNum,
				pageSize
			})
			return {
				code: 200,
				result: page
			}
		}catch(e){
			return {
				code: 500,
				msg: e.message
			}
		}
	}
	
	async getUserList() {
		let {
			keyword,
			role,
			city,
			pageNum,
			pageSize
		} = this.ctx.data
		try{
			let page = await this.service.user.getUserList({
				keyword,
				role,
				city,
				pageNum,
				pageSize
			})
			return {
				code: 200,
				result: page
			}
		}catch(e){
			return {
				code: 500,
				msg: e.message
			}
		}
	}
}
